from django.db import models
from django.utils import timezone

from application.static.models import Image
# 商品
# Create your models here.


class Goods(models.Model):
    type_zt = (
        (0, '下架'),
        (1, '上架'),
    )
    type_del = (
        (0, '显示'),
        (1, '隐藏'),
    )
    name = models.CharField(max_length=20, null=False, verbose_name='商品名称')
    price = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='商品原价')
    shop_price = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='商品售价')
    title = models.CharField(max_length=50, default=None, verbose_name='商品短标题')
    key_word = models.CharField(max_length=100, default=None, verbose_name='商品关键字')
    condition = models.TextField(default=None, verbose_name='商品描述')
    img = models.CharField(max_length=128, default=None, verbose_name='图片地址')
    # img = models.ForeignKey(Image, on_update=models.CASCADE)  # image 删除 这边不能执行删除
    content = models.TextField(default=None, verbose_name='商品简介')
    type = models.IntegerField(choices=type_zt, default=0, verbose_name='上、下架 商品')
    del_type = models.IntegerField(choices=type_del, default=0, verbose_name='删除商品')
    create_time = models.DateTimeField(default=timezone.now, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='最后更新时间')
